package com.example.administrator.printoutindemo;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Inventory implements Serializable{

	private int _inid;
	private int _mid;
	private int _spid;
	private String _nums;
	private String _material;
	private String _sname;
	private String _projectname;
	private String _supplier;
	private String _unit;
	private String _proid;

	// 将JSON对象转化为list
	public List<Inventory> getListFromJSON(String JsonStr) {
		List<Inventory> clist = new ArrayList<Inventory>();

		try {

			JSONArray jay = new JSONArray(JsonStr);// 将字符串转化为JSON数组

			for (int i = 0; i < jay.length(); i++) {
				JSONObject temp = (JSONObject) jay.get(i);

				Inventory n = new Inventory();

				n.set_inid(temp.getInt("inid"));
				n.set_mid(temp.getInt("mid"));
				n.set_spid(temp.getInt("spid"));
				n.set_nums(temp.getString("nums"));
				n.set_material(temp.getString("material"));
				n.set_sname(temp.getString("sname"));
				n.set_projectname(temp.getString("projectname"));
				n.set_supplier(temp.getString("supplier"));
				n.set_unit(temp.getString("unit"));
				n.set_proid(temp.getString("proid"));

				clist.add(n);

			}

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}

		return clist;

	}



	public String get_proid() {
		return _proid;
	}



	public void set_proid(String _proid) {
		this._proid = _proid;
	}



	public String get_unit() {
		return _unit;
	}


	public void set_unit(String _unit) {
		this._unit = _unit;
	}


	public int get_inid() {
		return _inid;
	}
	public void set_inid(int _inid) {
		this._inid = _inid;
	}
	public int get_mid() {
		return _mid;
	}
	public void set_mid(int _mid) {
		this._mid = _mid;
	}
	public int get_spid() {
		return _spid;
	}
	public void set_spid(int _spid) {
		this._spid = _spid;
	}
	public String get_nums() {
		return _nums;
	}
	public void set_nums(String _nums) {
		this._nums = _nums;
	}
	public String get_material() {
		return _material;
	}
	public void set_material(String _material) {
		this._material = _material;
	}
	public String get_sname() {
		return _sname;
	}
	public void set_sname(String _sname) {
		this._sname = _sname;
	}
	public String get_projectname() {
		return _projectname;
	}
	public void set_projectname(String _projectname) {
		this._projectname = _projectname;
	}
	public String get_supplier() {
		return _supplier;
	}
	public void set_supplier(String _supplier) {
		this._supplier = _supplier;
	}


}